package PostBar.Data;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;

import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Gettbs {
	private String urlString;
	public Gettbs(String urlString) {
		this.urlString=urlString;
	}
	public String gettbs() throws IOException {
		URL url = new URL(urlString);
		HttpURLConnection httpURLConnection =(HttpURLConnection) url.openConnection();
		httpURLConnection.setDoOutput(true);
		httpURLConnection.connect();
		BufferedReader bReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
		Pattern pattern = Pattern.compile("'tbs': \"(.*?)\"");
		String line=null;
		String tbs=null;
		String temp=null;
		while((line=bReader.readLine())!=null)
		{
			Matcher matcher = pattern.matcher(line);
			while (matcher.find()) {
				temp=matcher.group();
			}
			
		}
		tbs = temp.substring(temp.indexOf(":") + 3, temp.length() - 1);

		return tbs;
	}

}
